package com.zjyd.douyangfile.controller;

import com.zjyd.douyangcommoncore.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.dromara.x.file.storage.core.FileInfo;
import org.dromara.x.file.storage.core.FileStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@Tag(name = "视频文件")
@RequestMapping("/douyang/file/video")
public class VideoFileController {

    @Autowired
    private FileStorageService fileStorageService;//注入实列

    @Operation(summary = "视频上传")
    @PostMapping("/upload")
    public Result<FileInfo> upload2(MultipartFile file) {
        FileInfo fileInfo = fileStorageService.of(file)
                .setPath("video/") //保存到相对路径下，为了方便管理，不需要可以不写
                .upload();  //将文件上传到对应地方
        return Result.success(fileInfo);
    }

}
